- * SiriDB Server can now compile with gnu89/gnu90 (see issue #101)
\ No newline at end of file
+ * SiriDB Server can now compile with gnu89/gnu90. (see issue #101)
+
+ * Removed deprecated info- and loaddb requests.
+
\ No newline at end of file
typedef enum
{
- CPROTO_REQ_QUERY, /* (query, time_precision) */
- CPROTO_REQ_INSERT, /* series with points map/array */
- CPROTO_REQ_AUTH, /* (user, password, dbname) */
- CPROTO_REQ_PING, /* empty */
- CPROTO_REQ_INFO, /* empty */
- CPROTO_REQ_LOADDB, /* database path */
- CPROTO_REQ_REGISTER_SERVER, /* (uuid, host, port, pool) */
+ CPROTO_REQ_QUERY=0, /* (query, time_precision) */
+ CPROTO_REQ_INSERT=1, /* series with points map/array */
+ CPROTO_REQ_AUTH=2, /* (user, password, dbname) */
+ CPROTO_REQ_PING=3, /* empty */
+
+ /* Start internal usage */
+ CPROTO_REQ_REGISTER_SERVER=6, /* (uuid, host, port, pool) */
CPROTO_REQ_FILE_SERVERS, /* empty */
CPROTO_REQ_FILE_USERS, /* empty */
CPROTO_REQ_FILE_GROUPS, /* empty */
CPROTO_REQ_FILE_DATABASE, /* empty */
+ /* End linternal usage */
+
/* Administrative API request */
CPROTO_REQ_ADMIN=32, /* (user, password, request, {...}) */
} cproto_client_t;
typedef enum
{
/* success */
- CPROTO_RES_QUERY, /* {query response data} */
- CPROTO_RES_INSERT, /* {"success_msg": ...} */
- CPROTO_RES_AUTH_SUCCESS, /* empty */
- CPROTO_RES_ACK, /* empty */
- CPROTO_RES_INFO, /* [version, [dnname1, ...]] */
- CPROTO_RES_FILE, /* file content */
+ CPROTO_RES_QUERY=0, /* {query response data} */
+ CPROTO_RES_INSERT=1, /* {"success_msg": ...} */
+ CPROTO_RES_AUTH_SUCCESS=2, /* empty */
+ CPROTO_RES_ACK=3, /* empty */
+ CPROTO_RES_FILE=5, /* file content */
/* Administrative API success */
CPROTO_ACK_ADMIN=32, /* empty */
- CPROTO_ACK_ADMIN_DATA, /* [...] */
+ CPROTO_ACK_ADMIN_DATA=33, /* [...] */
/* errors 64-69 are errors with messages */
CPROTO_ERR_MSG=64, /* {"error_msg": ...} */
- CPROTO_ERR_QUERY, /* {"error_msg": ...} */
- CPROTO_ERR_INSERT, /* {"error_msg": ...} */
- CPROTO_ERR_SERVER, /* {"error_msg": ...} */
- CPROTO_ERR_POOL, /* {"error_msg": ...} */
- CPROTO_ERR_USER_ACCESS, /* {"error_msg": ...} */
- CPROTO_ERR, /* empty (use for unexpected errors)*/
- CPROTO_ERR_NOT_AUTHENTICATED, /* empty */
- CPROTO_ERR_AUTH_CREDENTIALS, /* empty */
- CPROTO_ERR_AUTH_UNKNOWN_DB, /* empty */
- CPROTO_ERR_LOADING_DB, /* empty */
- CPROTO_ERR_FILE, /* empty */
+ CPROTO_ERR_QUERY=65, /* {"error_msg": ...} */
+ CPROTO_ERR_INSERT=66, /* {"error_msg": ...} */
+ CPROTO_ERR_SERVER=67, /* {"error_msg": ...} */
+ CPROTO_ERR_POOL=68, /* {"error_msg": ...} */
+ CPROTO_ERR_USER_ACCESS=69, /* {"error_msg": ...} */
+ CPROTO_ERR=70, /* empty (use for unexpected errors)*/
+ CPROTO_ERR_NOT_AUTHENTICATED=71, /* empty */
+ CPROTO_ERR_AUTH_CREDENTIALS=72, /* empty */
+ CPROTO_ERR_AUTH_UNKNOWN_DB=73, /* empty */
+ CPROTO_ERR_FILE=75, /* empty */
/* Administrative API errors */
CPROTO_ERR_ADMIN=96, /* {"error_msg": ...} */
static void on_query(uv_stream_t * client, sirinet_pkg_t * pkg);
static void on_insert(uv_stream_t * client, sirinet_pkg_t * pkg);
static void on_ping(uv_stream_t * client, sirinet_pkg_t * pkg);
-static void on_info(uv_stream_t * client, sirinet_pkg_t * pkg);
-static void on_loaddb(uv_stream_t * client, sirinet_pkg_t * pkg);
static void on_reqfile(
uv_stream_t * client,
sirinet_pkg_t * pkg,
static void CLSERVER_send_pool_error(
uv_stream_t * stream,
sirinet_pkg_t * pkg);
-static int CLSERVER_on_info_cb(siridb_t * siridb, qp_packer_t * packer);
static void CLSERVER_on_register_server_response(
slist_t * promises,
siridb_server_async_t * server_reg);
case CPROTO_REQ_PING:
on_ping(client, pkg);
break;
- case CPROTO_REQ_INFO:
- on_info(client, pkg);
- break;
- case CPROTO_REQ_LOADDB:
- on_loaddb(client, pkg);
- break;
case CPROTO_REQ_REGISTER_SERVER:
on_register_server(client, pkg);
break;
}
}
-static void on_info(uv_stream_t * client, sirinet_pkg_t * pkg)
-{
- qp_packer_t * packer = sirinet_packer_new(128);
- if (packer != NULL)
- {
- qp_add_type(packer, QP_ARRAY_OPEN);
- qp_add_string(packer, SIRIDB_VERSION);
- qp_add_type(packer, QP_ARRAY_OPEN);
-
- if (!llist_walk(
- siri.siridb_list,
- (llist_cb) CLSERVER_on_info_cb,
- packer))
- {
- sirinet_pkg_t * package = sirinet_packer2pkg(
- packer,
- pkg->pid,
- CPROTO_RES_INFO);
-
- /* ignore result code, signal can be raised */
- sirinet_pkg_send(client, package);
- }
- else
- {
- qp_packer_free(packer);
- }
- }
-}
-
-/*
- * This function can raise a SIGNAL.
- */
-static void on_loaddb(uv_stream_t * client, sirinet_pkg_t * pkg)
-{
- qp_unpacker_t unpacker;
- qp_unpacker_init(&unpacker, pkg->data, pkg->len);
-
- qp_obj_t qp_dbpath;
- if (qp_next(&unpacker, &qp_dbpath) == QP_RAW)
- {
- char * dbpath = strndup(
- (const char *) qp_dbpath.via.raw, qp_dbpath.len);
-
- if (dbpath == NULL)
- {
- ERR_ALLOC
- }
- else
- {
- siridb_t * siridb = siridb_new(dbpath, LOCK_QUIT_IF_EXIST);
- if (siridb != NULL)
- {
- siridb->server->flags |= SERVER_FLAG_RUNNING;
-
- /* Force one heart-beat */
- siri_heartbeat_force();
- }
- sirinet_pkg_t * package = sirinet_pkg_new(
- pkg->pid,
- 0,
- (siridb == NULL) ?
- CPROTO_ERR_LOADING_DB : CPROTO_RES_ACK,
- NULL);
- if (package != NULL)
- {
- sirinet_pkg_send(client, package);
- }
- free(dbpath);
- }
- }
- else
- {
- log_error("Incorrect package received: 'on_loaddb'");
- }
-}
-
/*
* This function can raise a SIGNAL.
*/
}
}
-/*
- * Typedef: llist_cb
- * Returns 0 if successful or -1 and a SIGNAL is raised if not.
- */
-static int CLSERVER_on_info_cb(siridb_t * siridb, qp_packer_t * packer)
-{
- return qp_add_string(packer, siridb->dbname);
-}
-
/*
* Typedef: sirinet_promises_cb
*/
case CPROTO_REQ_INSERT: return "CPROTO_REQ_INSERT";
case CPROTO_REQ_AUTH: return "CPROTO_REQ_AUTH";
case CPROTO_REQ_PING: return "CPROTO_REQ_PING";
- case CPROTO_REQ_INFO: return "CPROTO_REQ_INFO";
- /* deprecated, used by the old SiriDB manage tool */
- case CPROTO_REQ_LOADDB: return "CPROTO_REQ_LOADDB";
+ /* start internal usage */
case CPROTO_REQ_REGISTER_SERVER: return "CPROTO_REQ_REGISTER_SERVER";
case CPROTO_REQ_FILE_SERVERS: return "CPROTO_REQ_FILE_SERVERS";
case CPROTO_REQ_FILE_USERS: return "CPROTO_REQ_FILE_USERS";
case CPROTO_REQ_FILE_GROUPS: return "CPROTO_REQ_FILE_GROUPS";
case CPROTO_REQ_FILE_DATABASE: return "CPROTO_REQ_FILE_DATABASE";
- /* end deprecated */
+ /* end internal usage */
case CPROTO_REQ_ADMIN: return "CPROTO_REQ_ADMIN";
case CPROTO_RES_INSERT: return "CPROTO_RES_INSERT";
case CPROTO_RES_AUTH_SUCCESS: return "CPROTO_RES_AUTH_SUCCESS";
case CPROTO_RES_ACK: return "CPROTO_RES_ACK";
-
- /* deprecated, used by the old SiriDB manage tool */
- case CPROTO_RES_INFO: return "CPROTO_RES_INFO";
case CPROTO_RES_FILE: return "CPROTO_RES_FILE";
- /* end deprecated */
-
case CPROTO_ACK_ADMIN: return "CPROTO_ACK_ADMIN";
case CPROTO_ACK_ADMIN_DATA: return "CPROTO_ACK_ADMIN_DATA";
case CPROTO_ERR_MSG: return "CPROTO_ERR_MSG";
case CPROTO_ERR_NOT_AUTHENTICATED: return "CPROTO_ERR_NOT_AUTHENTICATED";
case CPROTO_ERR_AUTH_CREDENTIALS: return "CPROTO_ERR_AUTH_CREDENTIALS";
case CPROTO_ERR_AUTH_UNKNOWN_DB: return "CPROTO_ERR_AUTH_UNKNOWN_DB";
-
- /* deprecated, used by the old SiriDB manage tool */
- case CPROTO_ERR_LOADING_DB: return "CPROTO_ERR_LOADING_DB";
case CPROTO_ERR_FILE: return "CPROTO_ERR_FILE";
- /* end deprecated */
case CPROTO_ERR_ADMIN: return "CPROTO_ERR_ADMIN";
case CPROTO_ERR_ADMIN_INVALID_REQUEST: return "CPROTO_ERR_ADMIN_INVALID_REQUEST";